Reading asp. net Request. ServerVariables []

  • 2020-05-12 02:30:24
  • OfStack

Get the IP address of the client, the code is as follows:

 
/// <summary> 
///  Get client IP address  
/// </summary> 
/// <returns></returns> 
public string GetClientIP() 
{ 
string userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; 
if (userIP == null) 
userIP = Request.ServerVariables["REMOTE_ADDR"]; 
return userIP; 
} 

ServerVariables -- server variable

Request.ServerVariables("Url")
Return server address
Request.ServerVariables("Path_Info")
Path information provided by the client
Request.ServerVariables("Appl_Physical_Path")
The physical path corresponding to the application metadata path
Request.ServerVariables("Path_Translated")
The path resulting from a virtual to physical mapping
Request.ServerVariables("Script_Name")
Name of the execution script
Request.ServerVariables("Query_String")
Query string
Request.ServerVariables("Http_Referer")
The requested string contains nothing
Request.ServerVariables("Server_Port")
The server port number to accept the request
Request.ServerVariables("Remote_Addr")
The IP address of the remote host making the request
Request.ServerVariables("Remote_Host")
The name of the remote host from which the request was made
Request.ServerVariables("Local_Addr")
Returns the server address to which the request was received
Request.ServerVariables("Http_Host")
Return server address
Request.ServerVariables("Server_Name")
The hostname, DNS address, or IP address of the server
Request.ServerVariables("Request_Method")
Request methods such as GET, HEAD, POST, and so on
Request.ServerVariables("Server_Port_Secure")
If the server port on which the request is received is a secure port, it is 1, otherwise it is 0
Request.ServerVariables("Server_Protocol")
The name and version of the protocol used by the server
Request.ServerVariables("Server_Software")
The name and version of the server software that answers the request and runs the gateway
Request.ServerVariables("All_Http")
All HTTP headers sent by the client with the prefix HTTP_
Request.ServerVariables("All_Raw")
All HTTP headers sent by the client have the same results as when the client sent them, without the prefix HTTP_
Request.ServerVariables("Appl_MD_Path")
The application's metadata path
Request.ServerVariables("Content_Length")
The length of the volume emitted by the client
Request.ServerVariables("Https")
If the request goes through a secure channel (SSL), ON is returned; if the request comes from a non-secure channel, OFF is returned
Request.ServerVariables("Instance_ID")
The ID number of the IIS instance
Request.ServerVariables("Instance_Meta_Path")
The metadata path of the IIS instance that responded to the request
Request.ServerVariables("Http_Accept_Encoding")
Return the contents like: gzip,deflate
Request.ServerVariables("Http_Accept_Language")
Return the contents like: en-us
Request.ServerVariables("Http_Connection")
Back to contents: Keep-Alive
Request.ServerVariables("Http_Cookie")
Returns: nVisiT%
2DYum=125;ASPSESSIONIDCARTQTRA=FDOBFFABJGOECBBKHKGPFIJI;ASPSESSIONIDCAQQTSRB=LKJJPLABABILLPCOGJGAMKAM;ASPSESSIONIDACRRSSRA=DK
HHHFBBJOJCCONPPHLKGHPB
Request.ServerVariables("Http_User_Agent")
Back to contents: Mozilla/4.0(compatible; MSIE6. 0; WindowsNT5. 1; SV1)
Request.ServerVariables("Https_Keysize")
The number of bits of the secure socket layer connection keyword, such as 128
Request.ServerVariables("Https_Secretkeysize")
The server verifies that the private keyword has a number of bits such as 1024
Request.ServerVariables("Https_Server_Issuer")
The issuer field for the server certificate
Request.ServerVariables("Https_Server_Subject")
The subject field of the server certificate
Request.ServerVariables("Auth_Password")
The password entered by the customer in the password dialog box when using the basic authentication mode
Request.ServerVariables("Auth_Type")
Is the authentication method used by the server to verify users when they access a protected script
Request.ServerVariables("Auth_User")
The user name of the proxy
Request.ServerVariables("Cert_Cookie")
Customer certificate ID of only 1
Request.ServerVariables("Cert_Flag")
If there is a client certificate, bit0 is 0. If the client certificate is invalid, bit1 is set to 1
Request.ServerVariables("Cert_Issuer")
The issuer field in the user certificate
Request.ServerVariables("Cert_Keysize")
The number of bits of the secure socket layer connection keyword, such as 128
Request.ServerVariables("Cert_Secretkeysize")
The server verifies that the private keyword has a number of bits such as 1024
Request.ServerVariables("Cert_Serialnumber")
The serial number field of the customer certificate
Request.ServerVariables("Cert_Server_Issuer")
The issuer field for the server certificate
Request.ServerVariables("Cert_Server_Subject")
The subject field of the server certificate
Request.ServerVariables("Cert_Subject")
The subject field of the client certificate
Request.ServerVariables("Content_Type")
The data type of form or HTTPPUT sent by the customer
Request.ServerVariables("HTTP_X_FORWARDED_FOR")
You can get direct IP behind the proxy (gateway), which of course must be supported by this proxy
1 hidden Request.ServerVariables parameters:
Request.ServerVariables("NUMBER_OF_PROCESSORS")
Request.ServerVariables("OS")
Request.ServerVariables("WINDIR")
Request.ServerVariables("TEMP")
Request.ServerVariables("TMP")
Request.ServerVariables("ComSpec")
Request.ServerVariables("Os2LibPath")
Request.ServerVariables("Path")
Request.ServerVariables("PATHEXT")
Request.ServerVariables("PROCESSOR_ARCHITECTURE")
Request.ServerVariables("PROCESSOR_IDENTIFIER")
Request.ServerVariables("PROCESSOR_LEVEL")
Request.ServerVariables("PROCESSOR_REVISION")
The native ip: < %=request.servervariables("remote_addr")% >
Server name: < %=Request.ServerVariables("SERVER_NAME")% >
Server IP: < %=Request.ServerVariables("LOCAL_ADDR")% >
Server port: < %=Request.ServerVariables("SERVER_PORT")% >
Server time: < %=now% >
IIS version: < %=Request.ServerVariables("SERVER_SOFTWARE")% >
Script timeout: < %=Server.ScriptTimeout% >
Path of this file: < %=server.mappath(Request.ServerVariables("SCRIPT_NAME"))% >
Number of server CPU: < %=Request.ServerVariables("NUMBER_OF_PROCESSORS")% >
Server interpreter engine: < %=ScriptEngine & "/"& ScriptEngineMajorVersion&"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion % >
Server operating system: < %=Request.ServerVariables("OS")% >
Supported file types: < %=Request.ServerVariables("HTTP_Accept")% >
File path to be accessed: < %=Request.ServerVariables("HTTP_url")% >
User agent information: < %=Request.ServerVariables("HTTP_USER_AGENT")% >

Related articles: